#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>


typedef struct perso
{

    SDL_Rect set;
    SDL_Surface *pic;

}perso;



int main()
{perso kheop;
SDL_Surface *screen,*fond,*obs,*noob,*fondb;
SDL_Event event;
SDL_Rect lol,obsset,noobs,cam;
int i=100000;
int j,a=1,n=56,k=0,s=8,g=0;

int quit=0;
const int FPS = 60;
        Uint32 start;
 cam.x=0;cam.y=0;
noobs.x=900;noobs.y=80;
obsset.x=350;obsset.y=600;
lol.x=0;lol.y=0;lol.h=280;lol.w=110;
kheop.set.x=0;kheop.set.y=0;
   SDL_Init(SDL_INIT_EVERYTHING);
screen = SDL_SetVideoMode( 1300, 714, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
    



fondb=IMG_Load("/home/hammamighassen/Bureau/hepha/background-ice-gameblanc.gif");
noob=IMG_Load("/home/hammamighassen/Bureau/hepha/NoobZoneLogo.jpg");
obs=IMG_Load("/home/hammamighassen/Téléchargements/pic.gif");
    fond=IMG_Load("/home/hammamighassen/Bureau/hepha/background ice game.jpg");
    kheop.pic=IMG_Load("/home/hammamighassen/Bureau/hepha/kk0.gif");Uint32 colorkey = SDL_MapRGB( kheop.pic->format, 255, 255, 255 );



SDL_BlitSurface(fondb,&cam,screen,NULL);
SDL_BlitSurface(fond,&cam,screen,NULL);

    SDL_BlitSurface(kheop.pic,NULL,screen,&kheop.set);
    SDL_Flip(screen);

kheop.set.y=350;
SDL_EnableKeyRepeat(70,35);

while(quit == 0){	start = SDL_GetTicks();g=0;

///////////////////////////////////////////////////////////////////////////
while (SDL_PollEvent(&event)){

/////////////////////////////////////////////////////////////////////////
if(
///////////////////////////////////////////////////////////////////////////

if(g==0)kheop.set.y+=7;
 if( event.type == SDL_QUIT ) { quit = 1; }
if(event.type==SDL_KEYDOWN)  if( event.key.keysym.sym==SDLK_RIGHT ) {kheop.set.x+=7;k-=0.4;i++;if(kheop.set.x>650){cam.x+=7;}if (kheop.set.x>432)if(event.type==SDL_KEYDOWN)  if( event.key.keysym.sym==SDLK_RIGHT ){



//kheop.set.y-=s;




}}

if(event.type==SDL_KEYDOWN) if( event.key.keysym.sym==SDLK_LEFT ) {kheop.set.x-=7;i--;if (kheop.set.x>432)if(event.type==SDL_KEYDOWN){


//kheop.set.y+=s;


}}


 if(event.type==SDL_KEYDOWN) if( event.key.keysym.sym==SDLK_UP  )
  {
a=1;
    for(j=0;j<(n/2);j++)
    {while (SDL_PollEvent(&event)) {
if(event.type==SDL_KEYDOWN) if( event.key.keysym.sym==SDLK_LEFT ) {kheop.set.x-=18;} 
if(event.type==SDL_KEYDOWN)  if( event.key.keysym.sym==SDLK_RIGHT ) {kheop.set.x+=18;}}
     

if(j==(n/4)) a=-a;

       kheop.set.y-=(1000/FPS)*a;
if (kheop.set.x>432)if(event.type==SDL_KEYDOWN)if( event.key.keysym.sym==SDLK_RIGHT ) {k-=0.4;kheop.set.y-=8*k;}
      SDL_BlitSurface(fondb,&cam,screen,NULL);
SDL_BlitSurface(fond,&cam,screen,NULL);
SDL_BlitSurface(kheop.pic,&lol,screen,&kheop.set);
SDL_BlitSurface(obs,NULL,fond,&obsset);
    SDL_Flip(screen);

}}

///////////////////////////////////////////////////////////////
//if (kheop.set.x>432)if(event.type==SDL_KEYDOWN)  if( event.key.keysym.sym==SDLK_RIGHT ) {kheop.set.x+=18;i++;kheop.set.y-=15;}
//if(event.type==SDL_KEYDOWN)if (kheop.set.x<432)  if( event.key.keysym.sym==SDLK_LEFT ) {kheop.set.x+=18;i++;kheop.set.y+=15;}







///////////////////////////////////////////////////////////////////////////
if(i%5==0){kheop.pic=IMG_Load("/home/hammamighassen/Bureau/hepha/kk0.gif");SDL_SetColorKey( kheop.pic, SDL_SRCCOLORKEY, colorkey );}
if(i%5==1){kheop.pic=IMG_Load("/home/hammamighassen/Bureau/hepha/kk1.gif");SDL_SetColorKey( kheop.pic, SDL_SRCCOLORKEY, colorkey );}
if(i%5==2){kheop.pic=IMG_Load("/home/hammamighassen/Bureau/hepha/kk2.gif");SDL_SetColorKey( kheop.pic, SDL_SRCCOLORKEY, colorkey );}
if(i%5==3){kheop.pic=IMG_Load("/home/hammamighassen/Bureau/hepha/kk3.gif");SDL_SetColorKey( kheop.pic, SDL_SRCCOLORKEY, colorkey );}
if(i%5==4){kheop.pic=IMG_Load("/home/hammamighassen/Bureau/hepha/kk4.gif");SDL_SetColorKey( kheop.pic, SDL_SRCCOLORKEY, colorkey );}
///////////////////////////////////////////////////////////////////////////   
SDL_BlitSurface(fondb,&cam,screen,NULL);
SDL_BlitSurface(fond,&cam,screen,NULL);
SDL_BlitSurface(kheop.pic,&lol,screen,&kheop.set);

    SDL_Flip(screen);


///////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////




///////////////////////////////////////////////////////////////////////////
if(event.type==SDL_KEYUP)if( event.key.keysym.sym==SDLK_RIGHT  ||  event.key.keysym.sym==SDLK_LEFT ||  event.key.keysym.sym==SDLK_UP  )
{kheop.pic=IMG_Load("/home/hammamighassen/Bureau/hepha/kk0.gif");SDL_SetColorKey( kheop.pic, SDL_SRCCOLORKEY, colorkey );
SDL_BlitSurface(fondb,&cam,screen,NULL);
SDL_BlitSurface(fond,&cam,screen,NULL);
SDL_BlitSurface(kheop.pic,&lol,screen,&kheop.set);SDL_Flip(screen);}
///////////////////////////////////////////////////////////////////////////

if(1000/FPS > SDL_GetTicks()-start) {
                        SDL_Delay(1000/FPS-(SDL_GetTicks()-start));
  }

 {SDL_BlitSurface(obs,NULL,fond,&obsset);SDL_Flip(screen);}
if((kheop.set.x+130)>360 && (kheop.set.x+20)<365 && (kheop.set.y+340)>55) {SDL_BlitSurface(noob,NULL,screen,&noobs);SDL_Flip(screen);}

}}


SDL_FreeSurface(kheop.pic);
SDL_FreeSurface(fond);
SDL_FreeSurface(screen);
SDL_FreeSurface(noob);
SDL_FreeSurface(obs);


}


